package com.jia.lidao.others.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jia.lidao.R;
import com.jia.lidao.others.enity.Collect;
import com.squareup.picasso.Picasso;

public class MineGoodsAdapter extends QuickAdapter<Collect.CollectBean.DataBean.GoodsBean> {
    private Context context;
    private OnCancleCollectListener onCancleCollectListener;
    public MineGoodsAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getLayoutID(int viewType) {
        return R.layout.mine_goods_adapter_item;
    }

    @Override
    public void convert(VH holder, final Collect.CollectBean.DataBean.GoodsBean itemData,final int position) {
        ImageView ivPic = holder.getView(R.id.iv_pic);
        Picasso.with(context).load(itemData.getThumb()).error(R.mipmap.collect_merchandise).into(ivPic);

        TextView tvMessage = holder.getView(R.id.tv_message);
        tvMessage.setText(itemData.getName());

        TextView tvPrice = holder.getView(R.id.tv_price);
        tvPrice.setText("¥ "+itemData.getPrice());

        TextView tvCanceCollect = holder.getView(R.id.tv_cancel_collect);
        tvCanceCollect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != onCancleCollectListener){
                    onCancleCollectListener.listener(itemData,position);
                }
            }
        });
    }

    public interface OnCancleCollectListener{
        void listener(Collect.CollectBean.DataBean.GoodsBean itemData, int position);
    }

    public void setOnCancleCollectListener(OnCancleCollectListener onCancleCollectListener) {
        this.onCancleCollectListener = onCancleCollectListener;
    }
}